﻿using B.S.DataBase.MyProject.Domain.Vendors;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure.Interface;
using MediatR;
using T.E.ERP.Read.API.Applicantions.Command.CientsCommand.QuearyClientsCommands;

namespace T.E.ERP.Read.API.Applicantions.CommandHandler.ClientsCommandHandler.GetClient
{
    /// <summary>
    /// 动态绑定供应商
    /// </summary>
    public class GetMaterialSupperHandler : IRequestHandler<GetMaterialSupperComand, APIResult<List<MaterialSupplier>>>
    {
        private readonly IBaseRepository<MaterialSupplier> _materialSupplier;

        public GetMaterialSupperHandler(IBaseRepository<MaterialSupplier> materialSupplier)
        {
            _materialSupplier = materialSupplier;
        }

        public Task<APIResult<List<MaterialSupplier>>> Handle(GetMaterialSupperComand request, CancellationToken cancellationToken)
        {
            APIResult<List<MaterialSupplier>> result = new APIResult<List<MaterialSupplier>>();
            result.Code = APIEnum.查询成功;
            result.Msg = APIEnum.查询成功.ToString();
            var list= _materialSupplier.GetAll().Result;
            result.data = list.ToList();
            return Task.FromResult(result);
        }
    }
}
